-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor(router-core): Reduce navigation work by making some properties non-reactive #4916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sheraff
merged 14 commits into
main
from
refactor-router-core-non-reactive-store-properties
Aug 11, 2025
Merged
refactor(router-core): Reduce navigation work by making some properties non-reactive #4916
Sheraff
merged 14 commits into
main
from
refactor-router-core-non-reactive-store-properties
Aug 11, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View your CI Pipeline Execution ↗ for commit fbdc46a
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-ssr-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-plugin
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-ssr-query-core
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-plugin
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-server-functions-client
@tanstack/start-server-functions-fetcher
@tanstack/start-server-functions-server
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
This was referenced Aug 11, 2025
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
documentation
Everything documentation related
package: react-router
package: router-core
package: solid-router
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some of the properties of a route match in the store do not need to be reactive (i.e. reactive = trigger the execution of all subscribers when they change).
This PR proposes we add a
_nonReactive
key for storing these properties.Changes to properties in
_nonReactive
can be made like on a regular object, without the need to call__store.setState
, and without making a shallow copy of the object.The following properties were moved to
_nonReactive
(but more would be welcome if we can find which ones):beforeLoadPromise
loaderPromise
pendingTimeout
loadPromise
displayPendingPromise
minPendingPromise
dehydrated
This results in the removal of 4
updateMatch
calls inrouter-core
. At least 1 of which is in the hot-path of a navigation (loadMatches
>validResolvedMatches.forEach
). And the removal of 2updateMatch
calls inpackages/react-router/src/Match.tsx
(and solid-router too).The
ssr
property was also updated to not be reactive, but kept outside of_nonReactive
because it is part of the public API. This removes another call toupdateMatch
. This key is an exception, and if in the future we find a need to have more "public but non-reactive" properties, we could considerselect
functionsThis PR adds a unit-test in
react-router
that counts how many times theselect
inside auseRouterState
hook is called during a navigation. Without this PR, the result of this test is 26 calls. With this PR, we're down to 19 calls.Should be a partial improvement of #4359